




/*
'===============================================================================
'  HNG.Portal.BL.TblThanhVienManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using HNG.Portal.BLL;
using HNG.Portal.DAL;
using HNG.Portal.DAL.EntityClasses;
using HNG.Portal.DAL.FactoryClasses;
using HNG.Portal.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Windows.Forms;
namespace HNG.Portal.BLL
{
	public class TblThanhVienManagerBase
	{
	    
		#region ColumnNames
		
				public const String Field_Id="Id";
				
				public const String Field_ThanhVienGroup="ThanhVienGroup";
				
				public const String Field_TenTruyCap="TenTruyCap";
				
				public const String Field_MatKhau="MatKhau";
				
				public const String Field_FullName="FullName";
				
				public const String Field_Role="Role";
				
				public const String Field_DienThoai="DienThoai";
				
				public const String Field_Email="Email";
				
				public const String Field_GioiTinh="GioiTinh";
				
				public const String Field_DiaChi="DiaChi";
				
				public const String Field_NgayTao="NgayTao";
				
				public const String Field_Count="Count";
				
				public const String Field_TrangThai="TrangThai";
				
		#endregion	
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public TblThanhVienManagerBase()
		{
			// Nothing for now.
		}
		public DataTable Clone()
		{
			DataTable dt = new DataTable();
						
			
			dt.Columns.Add(Field_Id,typeof(int));
			
						
			
			dt.Columns.Add(Field_ThanhVienGroup,typeof(string));
			
						
			
			dt.Columns.Add(Field_TenTruyCap,typeof(string));
			
						
			
			dt.Columns.Add(Field_MatKhau,typeof(string));
			
						
			
			dt.Columns.Add(Field_FullName,typeof(string));
			
						
			
			dt.Columns.Add(Field_Role,typeof(string));
			
						
			
			dt.Columns.Add(Field_DienThoai,typeof(string));
			
						
			
			dt.Columns.Add(Field_Email,typeof(string));
			
						
			
			dt.Columns.Add(Field_GioiTinh,typeof(string));
			
						
			
			dt.Columns.Add(Field_DiaChi,typeof(string));
			
						
			
			dt.Columns.Add(Field_NgayTao,typeof(DateTime));
			
						
			
			dt.Columns.Add(Field_Count,typeof(long));
			
						
			
			dt.Columns.Add(Field_TrangThai,typeof(bool));
			
			            
            return dt;			
		}
			
		public TblThanhVienEntity Convert_Entity(TblThanhVienEntity _TblThanhVienEntity,TblThanhVienEntity _TblThanhVienEntity_XML)
		{	
			
				
			_TblThanhVienEntity.Id= _TblThanhVienEntity_XML.Id;
				
			_TblThanhVienEntity.ThanhVienGroup= _TblThanhVienEntity_XML.ThanhVienGroup;
				
			_TblThanhVienEntity.TenTruyCap= _TblThanhVienEntity_XML.TenTruyCap;
				
			_TblThanhVienEntity.MatKhau= _TblThanhVienEntity_XML.MatKhau;
				
			_TblThanhVienEntity.FullName= _TblThanhVienEntity_XML.FullName;
				
			_TblThanhVienEntity.Role= _TblThanhVienEntity_XML.Role;
				
			_TblThanhVienEntity.DienThoai= _TblThanhVienEntity_XML.DienThoai;
				
			_TblThanhVienEntity.Email= _TblThanhVienEntity_XML.Email;
				
			_TblThanhVienEntity.GioiTinh= _TblThanhVienEntity_XML.GioiTinh;
				
			_TblThanhVienEntity.DiaChi= _TblThanhVienEntity_XML.DiaChi;
				
			_TblThanhVienEntity.NgayTao= _TblThanhVienEntity_XML.NgayTao;
				
			_TblThanhVienEntity.Count= _TblThanhVienEntity_XML.Count;
				
			_TblThanhVienEntity.TrangThai= _TblThanhVienEntity_XML.TrangThai;
				
			
			return _TblThanhVienEntity;
		}	
		
			
		public void InsertCollection(EntityCollection _Collection)
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
            {
                adapter.SaveEntityCollection(_Collection);
            }
		}

		public TblThanhVienEntity Insert(TblThanhVienEntity TblThanhVienEntity)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(TblThanhVienEntity, true);
			}
			return TblThanhVienEntity;
		}

		
		public TblThanhVienEntity Insert(int Id, string ThanhVienGroup, string TenTruyCap, string MatKhau, string FullName, string Role, string DienThoai, string Email, string GioiTinh, string DiaChi, DateTime NgayTao, long Count, bool TrangThai)
		{
			TblThanhVienEntity _TblThanhVienEntity = new TblThanhVienEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblThanhVienEntity.Id = Id;
				_TblThanhVienEntity.ThanhVienGroup = ThanhVienGroup;
				_TblThanhVienEntity.TenTruyCap = TenTruyCap;
				_TblThanhVienEntity.MatKhau = MatKhau;
				_TblThanhVienEntity.FullName = FullName;
				_TblThanhVienEntity.Role = Role;
				_TblThanhVienEntity.DienThoai = DienThoai;
				_TblThanhVienEntity.Email = Email;
				_TblThanhVienEntity.GioiTinh = GioiTinh;
				_TblThanhVienEntity.DiaChi = DiaChi;
				_TblThanhVienEntity.NgayTao = NgayTao;
				_TblThanhVienEntity.Count = Count;
				_TblThanhVienEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblThanhVienEntity, true);
			}
			return _TblThanhVienEntity;
		}

		public TblThanhVienEntity Insert(string ThanhVienGroup, string TenTruyCap, string MatKhau, string FullName, string Role, string DienThoai, string Email, string GioiTinh, string DiaChi, DateTime NgayTao, long Count, bool TrangThai)
		{
			TblThanhVienEntity _TblThanhVienEntity = new TblThanhVienEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblThanhVienEntity.ThanhVienGroup = ThanhVienGroup;
				_TblThanhVienEntity.TenTruyCap = TenTruyCap;
				_TblThanhVienEntity.MatKhau = MatKhau;
				_TblThanhVienEntity.FullName = FullName;
				_TblThanhVienEntity.Role = Role;
				_TblThanhVienEntity.DienThoai = DienThoai;
				_TblThanhVienEntity.Email = Email;
				_TblThanhVienEntity.GioiTinh = GioiTinh;
				_TblThanhVienEntity.DiaChi = DiaChi;
				_TblThanhVienEntity.NgayTao = NgayTao;
				_TblThanhVienEntity.Count = Count;
				_TblThanhVienEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblThanhVienEntity, true);
			}
			return _TblThanhVienEntity;
		}

		public bool Update(TblThanhVienEntity _TblThanhVienEntity)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(TblThanhVienFields.Id == _TblThanhVienEntity.Id);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_TblThanhVienEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}
		
		public bool Update(TblThanhVienEntity _TblThanhVienEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_TblThanhVienEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}

		public bool Update(int Id, string ThanhVienGroup, string TenTruyCap, string MatKhau, string FullName, string Role, string DienThoai, string Email, string GioiTinh, string DiaChi, DateTime NgayTao, long Count, bool TrangThai)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblThanhVienEntity _TblThanhVienEntity = new TblThanhVienEntity(Id);
				if (adapter.FetchEntity(_TblThanhVienEntity))
				{
				
					_TblThanhVienEntity.ThanhVienGroup = ThanhVienGroup;
					_TblThanhVienEntity.TenTruyCap = TenTruyCap;
					_TblThanhVienEntity.MatKhau = MatKhau;
					_TblThanhVienEntity.FullName = FullName;
					_TblThanhVienEntity.Role = Role;
					_TblThanhVienEntity.DienThoai = DienThoai;
					_TblThanhVienEntity.Email = Email;
					_TblThanhVienEntity.GioiTinh = GioiTinh;
					_TblThanhVienEntity.DiaChi = DiaChi;
					_TblThanhVienEntity.NgayTao = NgayTao;
					_TblThanhVienEntity.Count = Count;
					_TblThanhVienEntity.TrangThai = TrangThai;
					adapter.SaveEntity(_TblThanhVienEntity, true);
					toReturn = true;
				}
			}
			return toReturn;
		}

		public bool Delete(int Id)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblThanhVienEntity _TblThanhVienEntity = new TblThanhVienEntity(Id);
				if (adapter.FetchEntity(_TblThanhVienEntity))
				{
					adapter.DeleteEntity(_TblThanhVienEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("TblThanhVienEntity", null);
			}
		}
		
		
		public int DeleteById(int Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByThanhVienGroup(string ThanhVienGroup)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.ThanhVienGroup == ThanhVienGroup);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTenTruyCap(string TenTruyCap)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.TenTruyCap == TenTruyCap);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByMatKhau(string MatKhau)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.MatKhau == MatKhau);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByFullName(string FullName)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.FullName == FullName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByRole(string Role)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Role == Role);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDienThoai(string DienThoai)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.DienThoai == DienThoai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByEmail(string Email)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Email == Email);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByGioiTinh(string GioiTinh)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.GioiTinh == GioiTinh);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDiaChi(string DiaChi)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.DiaChi == DiaChi);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByNgayTao(DateTime NgayTao)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.NgayTao == NgayTao);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByCount(long Count)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Count == Count);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTrangThai(bool TrangThai)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblThanhVienEntity", filter);
			}
			return toReturn;
		}
		

		
		public TblThanhVienEntity SelectOne(int Id)
		{
			TblThanhVienEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblThanhVienEntity _TblThanhVienEntity = new TblThanhVienEntity(Id);
				if (adapter.FetchEntity(_TblThanhVienEntity))
				{
					toReturn = _TblThanhVienEntity;
				}
			}
			return toReturn;
		}

		// Return EntityCollection
		public EntityCollection SelectAll()
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection( new TblThanhVienEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, null, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}

		
		// Return EntityCollection
		public EntityCollection SelectById(int Id)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(int Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByThanhVienGroup(string ThanhVienGroup)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.ThanhVienGroup == ThanhVienGroup);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByThanhVienGroupRDT(string ThanhVienGroup)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.ThanhVienGroup == ThanhVienGroup);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTenTruyCap(string TenTruyCap)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.TenTruyCap == TenTruyCap);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTenTruyCapRDT(string TenTruyCap)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.TenTruyCap == TenTruyCap);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByMatKhau(string MatKhau)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.MatKhau == MatKhau);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByMatKhauRDT(string MatKhau)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.MatKhau == MatKhau);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByFullName(string FullName)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.FullName == FullName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByFullNameRDT(string FullName)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.FullName == FullName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByRole(string Role)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Role == Role);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByRoleRDT(string Role)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Role == Role);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDienThoai(string DienThoai)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.DienThoai == DienThoai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDienThoaiRDT(string DienThoai)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.DienThoai == DienThoai);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByEmail(string Email)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Email == Email);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByEmailRDT(string Email)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Email == Email);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByGioiTinh(string GioiTinh)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.GioiTinh == GioiTinh);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByGioiTinhRDT(string GioiTinh)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.GioiTinh == GioiTinh);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDiaChi(string DiaChi)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.DiaChi == DiaChi);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDiaChiRDT(string DiaChi)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.DiaChi == DiaChi);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByNgayTao(DateTime NgayTao)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.NgayTao == NgayTao);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByNgayTaoRDT(DateTime NgayTao)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.NgayTao == NgayTao);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByCount(long Count)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Count == Count);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByCountRDT(long Count)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.Count == Count);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTrangThai(bool TrangThai)
		{
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblThanhVienCollection, filter, 0, null);
			}
			return _TblThanhVienCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTrangThaiRDT(bool TrangThai)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblThanhVienCollection = new EntityCollection(new TblThanhVienEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblThanhVienFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblThanhVienCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		

	}
}
